<?php if (!defined('THINK_PATH')) exit();?><html>
    <head>
        <title>原材料新增</title>
        <link href="<?php echo (ADMIN_CSS_URL); ?>bootstrap.css" rel="stylesheet" />
        <link href="<?php echo (ADMIN_CSS_URL); ?>lz-style.css" rel="stylesheet" />
        <script src="<?php echo (ADMIN_JS_URL); ?>jquery.js"></script>
        <script src="<?php echo (ADMIN_JS_URL); ?>jquery.form.js"></script>
        <script src="<?php echo (ADMIN_JS_URL); ?>bootstrap.js"></script>
        <script src="<?php echo (ADMIN_JS_URL); ?>DatePicker/WdatePicker.js"></script>
        <script language="JavaScript">

            $(function () {
                $('#addform').ajaxForm({
                    beforeSubmit: checkForm, // pre-submit callback
                    success: complete, // post-submit callback
                    dataType: 'json'
                });
                function checkForm() {

                    if ('' == $.trim($('#MaterialCode').val())) {
                        $('#success').hide();
                        $('#error').html('[<?php echo (LB_MATERIALCODE); ?>]不能为空').show();
                        return false;
                    }

                    if ('' == $.trim($('#MaterialName').val())) {
                        $('#success').hide();
                        $('#error').html('[<?php echo (LB_MATERIALNAME); ?>]不能为空').show();
                        return false;
                    }

                    if ('' == $.trim($('#MaterialTypeID').val())) {
                        $('#success').hide();
                        $('#error').html('[<?php echo (LB_MATERIALTYPEID); ?>]不能为空').show();
                        return false;
                    }

                    if ('' == $.trim($('#MaterialModel').val())) {
                        $('#success').hide();
                        $('#error').html('[<?php echo (LB_MATERIALMODEL); ?>]不能为空').show();
                        return false;
                    }

                    if ('' == $.trim($('#MaterialUnit').val())) {
                        $('#success').hide();
                        $('#error').html('[<?php echo (LB_MATERIALUNIT); ?>]不能为空').show();
                        return false;
                    }

                    if ('' == $.trim($('#MaterialIMG').val())) {
                        $('#success').hide();
                        $('#error').html('[<?php echo (LB_MATERIALIMG); ?>]不能为空').show();
                        return false;
                    }

                    //可以在此添加其它判断
                }
                function complete(data) {
                    if (data.status === 1) {
                        $('#error').hide();
                        $('#success').html(data.info).show();
                    } else {
                        $('#success').hide();
                        $('#error').html(data.info).show();
                    }
                }

            });

        </script>

    </head>
    <body>
        <div class="container">
            <div class="row div_head" >
                <div class=" col-xs-6 col-sm-6 text-primary">
                    <?php echo ($loction); ?>
                </div>
                <div class="col-xs-6 col-sm-3"></div>
                <div class="col-xs-6 col-sm-3">
                    <a style="text-decoration: none" href="/ecs/index.php/Admin/Material/lst">【返回】</a>
                </div>
            </div>

            <hr />
            <div class="row div_form" >
                <form id="addform" action="/ecs/index.php/Admin/Material/add" method="post">

                    <div class="text-right col-xs-6 col-sm-3 div_required" ><label for="MaterialCode" class="control-label"><?php echo (LB_MATERIALCODE); ?>:</label></div>
                    <div class="col-xs-6 col-sm-3 div_text" >
                        <input type="text" id="MaterialCode" name="MaterialCode" class="form-control" placeholder="<?php echo (LB_MATERIALCODE); ?>"   maxlength="42"   required />
                    </div>
                    <div class="text-right col-xs-6 col-sm-3 div_required" ><label for="MaterialName" class="control-label"><?php echo (LB_MATERIALNAME); ?>:</label></div>
                    <div class="col-xs-6 col-sm-3 div_text" >
                        <input type="text" id="MaterialName" name="MaterialName" class="form-control" placeholder="<?php echo (LB_MATERIALNAME); ?>"   maxlength="100"   required />
                    </div>
                    <div class="text-right col-xs-6 col-sm-3 div_required" ><label for="MaterialTypeID" class="control-label"><?php echo (LB_MATERIALTYPEID); ?>:</label></div>
                    <div class="col-xs-6 col-sm-3 div_text" >
                        <!--
                        <input type="text" id="MaterialTypeID" name="MaterialTypeID" class="form-control" placeholder="<?php echo (LB_MATERIALTYPEID); ?>"   maxlength="42"   required />
                        -->
                        <select id="MaterialTypeID" name="MaterialTypeID" class="form-control"   required>
                            <option value="" style="display: none"></option>
                            <?php if(is_array($LSTMATERIALTYPEID)): foreach($LSTMATERIALTYPEID as $k=>$row): ?><option value="<?php echo ($k); ?>"><?php echo ($row); ?></option><?php endforeach; endif; ?>
                        </select>
                    </div>
                    <div class="text-right col-xs-6 col-sm-3 div_required" ><label for="MaterialModel" class="control-label"><?php echo (LB_MATERIALMODEL); ?>:</label></div>
                    <div class="col-xs-6 col-sm-3 div_text" >
                        <input type="text" id="MaterialModel" name="MaterialModel" class="form-control" placeholder="<?php echo (LB_MATERIALMODEL); ?>"   maxlength="50"   required />
                    </div>
                    <div class="text-right col-xs-6 col-sm-3 div_required" ><label for="MaterialUnit" class="control-label"><?php echo (LB_MATERIALUNIT); ?>:</label></div>
                    <div class="col-xs-6 col-sm-3" >
                        <select id="MaterialUnit" name="MaterialUnit" class="form-control"   required>
                            <option value="" style="display: none"></option>
                            <?php if(is_array($GV_Enum["MaterialUnit"])): foreach($GV_Enum["MaterialUnit"] as $k=>$row): ?><option value="<?php echo ($k); ?>"><?php echo ($k); ?>-<?php echo ($row); ?></option><?php endforeach; endif; ?>
                        </select>
                    </div>
                    <div class="text-right col-xs-6 col-sm-3 div_required" ><label for="MaterialIMG" class="control-label"><?php echo (LB_MATERIALIMG); ?>:</label></div>
                    <div class="col-xs-6 col-sm-3 div_text" >
                        <input type="text" id="MaterialIMG" name="MaterialIMG" class="form-control" placeholder="<?php echo (LB_MATERIALIMG); ?>"   maxlength="42"   required />
                    </div>
                    <div class="text-right col-xs-6 col-sm-3 " ><label for="MaterialSIMG" class="control-label"><?php echo (LB_MATERIALSIMG); ?>:</label></div>
                    <div class="col-xs-6 col-sm-3 div_text" >
                        <input type="text" id="MaterialSIMG" name="MaterialSIMG" class="form-control" placeholder="<?php echo (LB_MATERIALSIMG); ?>"   maxlength="42"    />
                    </div>
                    <div class="text-right col-xs-6 col-sm-3 " ><label for="MaterialDesc" class="control-label"><?php echo (LB_MATERIALDESC); ?>:</label></div>
                    <div class="col-xs-6 col-sm-3 div_text" >
                        <input type="text" id="MaterialDesc" name="MaterialDesc" class="form-control" placeholder="<?php echo (LB_MATERIALDESC); ?>"   maxlength="100"    />
                    </div>

                    <div class="col-xs-6 col-sm-3">
                        <input type="submit" id="search"  class="btn btn-default" value="提交">
                        <input type="reset" class="btn btn-default" value="清 空">
                    </div>

                </form>
            </div>
            <div id="error" class="row text-danger"></div>
            <div id="success" class="row text-success"></div>

        </div>

    </body>
</html>